﻿#ifndef MYPUSHBUTTONCOPY_H
#define MYPUSHBUTTONCOPY_H

#include <QWidget>
#include <QPushButton>
#include <QPainter>
#include <QMouseEvent>
#include <QApplication>

#include "mynamespace.h"

QT_BEGIN_NAMESPACE

class MyPushButtonCopyPrivate;
class MyPushButtonCopy : public QPushButton
{
    Q_OBJECT

    Q_PROPERTY(int imageLayerIndex READ getImageLayerIndex WRITE setImageLayerIndex)

    Q_PROPERTY(int sourceDeviceIndex READ getSourceDeviceIndex WRITE setSourceDeviceIndex)
    Q_PROPERTY(int destinationDeviceIndex READ getDestinationDeviceIndex WRITE setDestinationDeviceIndex)

    Q_PROPERTY(My::ObjectType objectType READ getObjectType WRITE setObjectType)
    Q_PROPERTY(int sourceObjectIndex READ getSourceObjectIndex WRITE setSourceObjectIndex)
    Q_PROPERTY(int destinationObjectIndex READ getDestinationObjectIndex WRITE setDestinationObjectIndex)

    Q_PROPERTY(bool displayEnable READ getDisplayEnable WRITE setDisplayEnable)
    Q_PROPERTY(bool displayDefault READ getDisplayDefault WRITE setDisplayDefault)

    Q_PROPERTY(My::PushButtonCopyOperate pushButtonCopyOperate READ getPushButtonCopyOperate WRITE setPushButtonCopyOperate)
    Q_PROPERTY(int coilOfRegisterIndex READ getCoilOfRegisterIndex WRITE setCoilOfRegisterIndex)

public:
    explicit MyPushButtonCopy(QWidget *parent = nullptr);
    ~MyPushButtonCopy();

    /* Property Interface */
    int getImageLayerIndex() const;
    void setImageLayerIndex(int imageLayerInd);

    int getSourceDeviceIndex() const;
    void setSourceDeviceIndex(int deviceInd);

    int getDestinationDeviceIndex() const;
    void setDestinationDeviceIndex(int deviceInd);

    My::ObjectType getObjectType() const;
    void setObjectType(My::ObjectType);

    int getSourceObjectIndex() const;
    void setSourceObjectIndex(int);

    int getDestinationObjectIndex() const;
    void setDestinationObjectIndex(int);

    bool getDisplayEnable() const;
    void setDisplayEnable(bool);

    bool getDisplayDefault() const;
    void setDisplayDefault(bool);

    My::PushButtonCopyOperate getPushButtonCopyOperate() const;
    void setPushButtonCopyOperate(My::PushButtonCopyOperate);

    int getCoilOfRegisterIndex() const;
    void setCoilOfRegisterIndex(int);

protected:
    void paintEvent(QPaintEvent *ev) override;

    void enterEvent(QEvent *ev) override;
    void leaveEvent(QEvent *ev) override;
    void mousePressEvent(QMouseEvent *ev) override;
    void mouseReleaseEvent(QMouseEvent *ev) override;
    void mouseMoveEvent(QMouseEvent *ev) override;

private:
    Q_DISABLE_COPY(MyPushButtonCopy)
    MyPushButtonCopyPrivate *d;

};

QT_END_NAMESPACE

#endif // MYPUSHBUTTONCOPY_H
